package org.bitoy.shimmer.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

@Configuration
public class SwaggerConfig {
    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.OAS_30)
                .groupName("Test")
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
                .apis(RequestHandlerSelectors.basePackage("org.bitoy.shimmer.adapter.controller"))
                .paths(PathSelectors.any())
                .build();
    }

//    @Bean
//    public Docket docket(@org.jetbrains.annotations.NotNull Environment environment) {
//        Profiles profiles = Profiles.of("dev", "test");
//        boolean flag = environment.acceptsProfiles(profiles);
//        return new Docket(DocumentationType.OAS_30)
//                //.enable(flag)
//                .groupName("User")
//                .apiInfo(apiInfo())
//                .select()
//                .apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
//                .apis(RequestHandlerSelectors.basePackage("org.bitoy.shimmer.adapter.controller"))
//                .paths(PathSelectors.any())
//                .build();
//    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("shimmer接口文档")
                .description("文档描述")
                .contact(new Contact("joby", "www.abc.com", "abc@qq.com"))
                .version("1.0")
                .build();
    }
}
